#include<iostream>
#include<Eigen/Core>
#include<Eigen/Geometry>
using namespace std;
using namespace Eigen;



int main(int argc, char** argv){
	MatrixXd m1(3,3);	//默认为<double, n, n>
	//Matrix<int, 3, 3> m1;
	m1 << 1, 1, 1, 2, 2, 2, 3, 3, 3;
	cout<<m1<<endl;

	//算术运算
	
	//1)矩阵乘法
	MatrixXd m2(3,1);
	m2 << 1, 1, 1;
	MatrixXd m3;
	m3 = m1 * m2;   
	cout<<"矩阵乘法:\n"<<m3<<endl;

	//2)点乘(只适用于向量)
	Vector3d v1, v2;
	v1 << 1, 2, 3;
	v2 << 0, 1, 2;
	int a = v1.dot(v2);
	cout<<"点乘:\n"<<a<<endl;
	//叉乘(包含在Geometry模块中	)
	cout <<"叉乘:\n" <<v1.cross(v2) <<endl;
	//cout<<v3<<endl;

	//3）转置
	cout<<"置换前:\n"<<m1<<endl;
	cout<<"置换后:\n"<<m1.transpose()<<endl;
	Matrix2d m4;
	m4 << 1, 2, 3, 4;
	cout<<"adjoint:\n"<<m4.adjoint()<<endl;

	//运算
	cout<<"log:"<<m1.array().log()<<endl;

	//特殊矩阵
	MatrixXd x1, x2, x3, x4;
	Matrix3d x5;
	VectorXd v3;
	x1 = MatrixXd::Zero(4, 4);
	cout<<"零矩阵:\n"<<x1<<endl;
	x2 = MatrixXd::Ones(3, 3);
	cout<<"单位矩阵:\n"<<x2<<endl;
	x3 = MatrixXd::Constant(3, 3, 5); //(raws, cols, value)
	cout<<"常数矩阵:\n"<<x3<<endl;
	x4 = MatrixXd::Random(3,3);
	cout<<"随机矩阵:\n"<<x4<<endl;
	
	v3 = VectorXd::LinSpaced(10, 1, 10); //(size, low, high)
	cout<<"空间向量:\n"<<v3<<endl;

	cout<<v3.array().log()<<endl;






	return 0;
}
